package com.yungu.swift.admin.route.operation;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yungu.swift.base.ResponseData;
import com.yungu.swift.base.model.PageVo;
import com.yungu.swift.base.model.admin.AdminParam;
import com.yungu.swift.common.model.dto.CommonSystemMessageDto;
import com.yungu.swift.common.model.param.AdminNoticePageParam;
import com.yungu.swift.common.model.param.AdminNoticeParam;
import com.yungu.swift.common.service.CommonSystemMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : cuixiuyin
 * @date : 2019/8/30
 */
@RestController
@RequestMapping("/admin/v1/operation/notice")
@Api(value = "【运营管理】", tags = "公告管理")
public class NoticeAdmin {

    @Reference
    private CommonSystemMessageService commonSystemMessageService;

    @RequestMapping(value = "/queryPage", method = RequestMethod.POST)
    @ApiOperation(value = "管理员公告信息分页查询", httpMethod = "POST")
    public ResponseData<PageVo<CommonSystemMessageDto>> queryPage(@RequestBody AdminNoticePageParam noticePageParam) {
        return commonSystemMessageService.queryPage(noticePageParam);
    }

    @RequestMapping(value = "/sysQueryPage", method = RequestMethod.POST)
    @ApiOperation(value = "用户公告信息分页查询", httpMethod = "POST")
    public ResponseData<PageVo<CommonSystemMessageDto>> sysQueryPage(@RequestBody AdminNoticePageParam noticePageParam) {
        return commonSystemMessageService.sysQueryPage(noticePageParam);
    }

    @RequestMapping(value = "/unreadNum", method = RequestMethod.POST)
    @ApiOperation(value = "获取用户未读信息量", httpMethod = "POST")
    public ResponseData<Integer> unreadNum(@RequestBody AdminParam adminParam) {
        return commonSystemMessageService.sysUnreadNum(adminParam);
    }

    @RequestMapping(value = "/saveOrUpdate", method = RequestMethod.POST)
    @ApiOperation(value = "新增或更新系统公告", httpMethod = "POST")
    public ResponseData<Boolean> saveOrUpdate(@RequestBody AdminNoticeParam adminNoticeParam) {
        return commonSystemMessageService.saveOrUpdate(adminNoticeParam);
    }
}
